﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace DAO
{
    public static class HoaDon_GiamGiaDAO
    {
        public static QL_HuongRungEntities db = new QL_HuongRungEntities();
        public static List<HOADON_GIAMGIA> layDSGG()
        {
            List<HOADON_GIAMGIA> arrHDGG = new List<HOADON_GIAMGIA>();
            arrHDGG = db.HOADON_GIAMGIA.ToList();
            return arrHDGG;
        }

        public static double layTiLeGiamGia(int diemTichLuy)
        {
            double tiLeGiamGia = 0;
            var temp = db.HOADON_GIAMGIA.Where(p => p.DiemTichLuy <= diemTichLuy)
                    .Max(p => p.DiemTichLuy);

            tiLeGiamGia = db.HOADON_GIAMGIA.Where(p => p.DiemTichLuy == temp).Single().TiLeGiamGia;
            return tiLeGiamGia;
        }
    }
}
